package com.robusta.cityuate.base;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;

import com.actionbarsherlock.app.SherlockMapActivity;
import com.actionbarsherlock.view.Window;
import com.robusta.cityuate.CityuateApplication;
import com.robusta.cityuate.activities.LoginActivity;
import com.robusta.cityuate.utils.Token;

public abstract class CityuateMapActivity extends SherlockMapActivity {

	
	BroadcastReceiver closeReceiver=new BroadcastReceiver() {
		@Override
		public void onReceive(Context context, Intent intent) {
			finish();
			
		}
	};
	
	@Override
	protected void onCreate(Bundle arg0) {
		if(Token.getToken(this)==null)
		{
			startActivity(new Intent(this, LoginActivity.class));
			finish();
		}
		super.onCreate(arg0);
		requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
		setSupportProgressBarIndeterminateVisibility(false);
		registerReceiver(closeReceiver, new IntentFilter(CityuateApplication.CLOSE_TAG));
	}
	
	@Override
	protected abstract boolean isRouteDisplayed();
	
	@Override
	protected void onStart() {
		super.onStart();
		setSupportProgressBarIndeterminateVisibility(false);
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		setSupportProgressBarIndeterminateVisibility(false);
	}

	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		unregisterReceiver(closeReceiver);
		
	}
}
